package cn.rbac.action;

import java.util.List;

import cn.rbac.model.User;
import cn.rbac.service.UserManager;

import com.opensymphony.xwork2.ActionSupport;

public class UserAction extends ActionSupport{
	private UserManager userManager=new UserManager();
	private List<User> userList;
	private String comfirmPassword;
	private User user;
	private int userId;
	

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String index(){
		return SUCCESS;
	}
	
	@Override
	public String execute(){
		return SUCCESS;
	}
	
	public String userDel() {
		userManager.delUserById(userId);
		return "redirect";
	}
	
	public String userAdd(){
		if(userManager.add(user)){
			return "redirect";
		}
		return ERROR;
	}
	
	public  String userList() {
		System.out.println("call");
		userList=userManager.getUserList();
		if(userList!=null){
			return SUCCESS;
		}
		return ERROR;
	}
	
	public String userInput(){
		return INPUT;
	}

	public List<User> getUserList() {
		return userList;
	}

	public void setUserList(List<User> userList) {
		this.userList = userList;
	}
	
	public UserManager getUserManager() {
		return userManager;
	}

	public void setUserManager(UserManager userManager) {
		this.userManager = userManager;
	}
	
	public String getComfirmPassword() {
		return comfirmPassword;
	}

	public void setComfirmPassword(String comfirmPassword) {
		this.comfirmPassword = comfirmPassword;
	}
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
}
